{\rtf0\ansi{\fonttbl\f0\fswiss Helvetica;}
\paperw16240
\paperh10200
\margl40
\margr40
{\colortbl;\red255\green0\blue0;\red0\green0\blue0;\red255\green109\blue0;\red61\green0\blue0;\red0\green41\blue0;}
\pard\tx520\tx1060\tx1600\tx2120\tx2660\tx3200\tx3720\tx4260\tx4800\tx5320\f0\b0\i\ulnone\fs28\gray300\fc1\cf1 // SyntaxItem.m
\i0\gray0\fc2\cf2 \
\

\b #import
\b0  
\gray551\fc3\cf3 "SyntaxItem.h"
\gray0\fc2\cf2 \
\

\fs36 @implementation SyntaxItem
\fs28 \
\

\fs36 - free\

\fs28 \{\
	[regularExpression free];\
	[matchedSampleText free];\
	free(regularExpressionText);\
	
\b return
\b0  [
\b super
\b0  free];\
\}\
\

\fs36 - read:(NXTypedStream *)stream\

\fs28 \{\
    [
\b super
\b0  read:stream];\
	[regularExpression free];\
	regularExpression = NXReadObject(stream);\
	[matchedSampleText free];\
	matchedSampleText = NXReadObject(stream);\
	[matchedSampleText setTextColor:NXReadColor(stream)];\
    
\b return
\b0  
\b self
\b0 ;\
\}\
\

\fs36 - write:(NXTypedStream *)stream\

\fs28 \{\
    [
\b super
\b0  write:stream];\
	NXWriteRootObject(stream, regularExpression);\
	NXWriteRootObject(stream, matchedSampleText);\
	NXWriteColor(stream, [matchedSampleText textColor]);\
    
\b return
\b0  
\b self
\b0 ;\
\}\
\

\fs36 - getRegularExpression\

\fs28 \{\
	
\b return
\b0  regularExpression;\
\}\
\

\fs36 - (char *)getRegularExpressionText\

\fs28 \{\
	
\b int
\b0  length = [regularExpression textLength];\
\
	free(regularExpressionText);\
	
\b if
\b0  (!(regularExpressionText = malloc(length + 
\gray71\fc4\cf4 1
\gray0\fc2\cf2 ))) \{\
		NXRunAlertPanel(
\gray551\fc3\cf3 "Error"
\gray0\fc2\cf2 , 
\gray551\fc3\cf3 "malloc() failed"
\gray0\fc2\cf2 , 
\gray71\fc4\cf4 0
\gray0\fc2\cf2 , 
\gray71\fc4\cf4 0
\gray0\fc2\cf2 , 
\gray71\fc4\cf4 0
\gray0\fc2\cf2 );\
		
\b return
\b0  
\gray551\fc3\cf3 ""
\gray0\fc2\cf2 ;\
	\}\
	
\b if
\b0  ([regularExpression getSubstring:regularExpressionText start:
\gray71\fc4\cf4 0
\gray0\fc2\cf2  length:length] <= 
\gray71\fc4\cf4 0
\gray0\fc2\cf2 ) \{\

\i\gray300\fc1\cf1 //		NXRunAlertPanel("Error", "Can't get regular expression substring", 0, 0, 0);
\i0\gray0\fc2\cf2 \
		
\b return
\b0  
\gray551\fc3\cf3 ""
\gray0\fc2\cf2 ;\
	\}\
	regularExpressionText[length] = 
\gray71\fc4\cf4 0
\gray0\fc2\cf2 ;\
	
\b return
\b0  regularExpressionText;\
\}\
\

\fs36 - getMatchedSampleText\

\fs28 \{\
	
\b return
\b0  matchedSampleText;\
\}\
\

\fs36 - (void)setRegularExpression:re\

\fs28 \{\
	NXStream *stream = [re stream];\
	[regularExpression free];\
	NXSeek(stream, 
\gray71\fc4\cf4 0
\gray0\fc2\cf2 L, 
\gray93\fc5\cf5 NX_FROMSTART
\gray0\fc2\cf2 );\
	regularExpression = [[[Text alloc] init] readText:stream];\
	[regularExpression setFont:[re font]];\
\}\
\

\fs36 - (void)setMatchedSampleText:text\

\fs28 \{	\
	NXStream *stream = [text stream];\
	[matchedSampleText free];\
	NXSeek(stream, 
\gray71\fc4\cf4 0
\gray0\fc2\cf2 L, 
\gray93\fc5\cf5 NX_FROMSTART
\gray0\fc2\cf2 );\
	matchedSampleText = [[Text alloc] init];\
	[matchedSampleText readText:stream];\
	[matchedSampleText setFont:[text font]];\
	[matchedSampleText setTextColor:[text textColor]];\
\}\
\

\b @end
\b0 \

}
